(function($) { 
	//喜欢、值得、不值得等操作
	$.guang.judgement = {
		//喜欢第一次提交
		identityCallback : function(o, commentType, desirableType){},
		//喜欢重复提交
		repeatIdentityClk : function(o, commentType, desirableType){},
		//提交按钮操作
		awardClk : function(o){
			var html = ""
			+'<div id="awardDialog" class="g-dialog" style="width:400px;z-index: 9999; top: 363.5px; left: 643px; position: fixed; display: block; ">'
				+'<div class="dialog-content">'
					+'<div class="hd"><h3>你喜欢，逛买单</h3></div>'
					+'<div class="bd clearfix tac">'
						+'<span style="color:#E26;font-size:16px;font-weight:bold;line-height:30px;">恭喜，你中奖了</span><br/>'
						+'<span style="font-size:14px;line-height:30px;">请在规定时间内领取神秘奖品</span><br/>'
						+'<a href="'+GUANGER.path+'/account/award" target="_blank" class="bbl-btn award-tag mt20" style="margin-left:148px;cursor:pointer;">查看</a>'
					+'</div>'
					+'<a class="close" href="javascript:;"></a>'
				+'</div>'
			+'</div>';
			$("body").append(html);
			$("#awardDialog").overlay({
				top: 'center',
				mask: {
					color: '#000',
					loadSpeed: 200,
					opacity: 0.3
				},
				closeOnClick: true,
				load: true,
				onClose: function() {
					$("#awardDialog,#exposeMask").remove();
				}				
			});
			$(".award-tag").unbind();
			$(".award-tag").bind("click",function(){
				$("#awardDialog,#exposeMask").overlay().close();
				return true;
			})	
		},
		identityOper:function(o, productId, commentType){
			var ajaxUrl = (commentType == "0") ? "/baobei/favor":"/baobei/identity",
			sid = "";
			if(o.data("sid")){
				sid = o.data("sid");
			}
			$.ajax({
			   url: GUANGER.path + ajaxUrl,
			   type : "post",
			   dataType: "json",
			   data: {
				   productId : productId,
				   identify : commentType =="1"?"1":"0",
				   sid : sid
			   },
			   success: function(data){
				   var $json = data;
				   switch($json.code){
				   		case 100 :
				   			$.guang.judgement.identityCallback(o, commentType);
				   			break;
				   		case 101:
				   			$.guang.tip.conf.tipClass = "tipmodal tipmodal-error";
				   			$.guang.tip.show(o, $json.msg);
				   			break;
				   		case 103 : //喜欢、值得、不值得 重复提交后数据不做操作
				   			$.guang.judgement.repeatIdentityClk(o, $json.desirable);
				   			break;
						case 666 : //中奖了！
				   			$.guang.judgement.awardClk(o);
				   			break;
				   }
			   }
			});			
		},
		//提交成功操作
		cmtSubmitOkClk : function(){},
		//提交失败操作
		cmtSubmitErrorClk : function(){},
		//提交喜欢评论内容操作
		cmtSubmit : function(productId, dialogObj, o, type){
			var commentContent = $.guang.util.trim(o.find("textarea[name='commentContent']").val());
			var commentType = o.find("input[name='commentType']").val(); 
			var $errorRow = dialogObj.find(".error-row");
			$this = o;
			//评论数不能少于2个中文汉字
			if(commentContent != "" && $.guang.util.getStrLength(commentContent) >= 2){
				if($.guang.util.getStrLength(commentContent) < 256){
					$.ajax({
						url: GUANGER.path+"/baobei/comment",
						type : "post",
						dataType: "json",
						data: {
							productId : productId,
							commentContent : commentContent,
							commentType : commentType
						},
						success: function(data){
						   var $json = data;
						   switch($json.code){
								case 100:
								   $.guang.tip.conf.tipClass = "tipmodal tipmodal-ok";
								   $.guang.tip.show($this,"评论发表成功！");
								   $.guang.judgement.cmtSubmitOkClk();
								  break;
								case 101 ://错误
								   $.guang.tip.conf.tipClass = "tipmodal tipmodal-error";
								   $.guang.tip.show($this,$json.msg);
								   $.guang.judgement.cmtSubmitErrorClk();
								   break;
						   }
					   }
					});
				}else{//超过256个汉字提示
					$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
					$.guang.tip.show($this,">_< 评论内容不能超过256个汉字！");
				}
			}else{//评论为空提示
				$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
				//$.guang.tip.show($this,">_< 评论内容不能为空！");
				$.guang.tip.show($this,">_< 你的评论太短啦，再多说几句吧！");
			}
		},
		//评论加标签提交成功操作
		commentAndAddTagsSubmitOkClk : function($json){},
		//评论加标签提交失败操作
		commentAndAddTagsSubmitErrorClk : function($json){},
		//提交评论加标签操作
		commentAndAddTagsSubmit : function(data, o){
			$this = o;
			$.ajax({
				url: GUANGER.path+"/baobei/commentMore",
				type : "post",
				dataType: "json",
				data: data,
				success: function(data){
					var $json = data;
					switch($json.code){
						case 100:
							$.guang.tip.conf.tipClass = "tipmodal tipmodal-ok";
							$.guang.tip.show($this,"评论发表成功！");
							$.guang.judgement.commentAndAddTagsSubmitOkClk($json);
						break;
						case 101 ://错误
							$.guang.tip.conf.tipClass = "tipmodal tipmodal-error";
							$.guang.tip.show($this,$json.msg);
							$.guang.judgement.commentAndAddTagsSubmitErrorClk($json);
						break;
						case 444 ://账户被冻结,立刻登出
							alert($json.msg);
							window.location.href="http://guang.com/logout";
						break;
						case 440 ://账户被冻结,不能评论
							alert($json.msg);
							$.guang.judgement.commentAndAddTagsSubmitErrorClk($json);
						break;
					}
				}
			});
		},
		//喜欢主题成功
		taoluenzuLikeCallback : function(o, commentType, desirableType){},
		//喜欢主题重复
		repeatTaoluenzuLikeClk : function(o, commentType, desirableType){},
		//喜欢主题操作
		taoluenzuLikeSubmit : function(o,json){
			var config = $.extend({
				url:"",
				type:"post",
				dataType:"json",
				data:{}
			},json || {});
			$.ajax({
				url: config.url,
				type : config.type,
				dataType: config.dataType,
				data: config.data,
				success: function(data){
					switch(data.code){
						case 100:
							$.guang.judgement.taoluenzuLikeCallback(o,data);
						break;
						case 101 ://错误
							$.guang.tip.conf.tipClass = "tipmodal tipmodal-error";
							$.guang.tip.show(o,data.msg);
						break;
						case 103 : //喜欢重复
							$.guang.judgement.repeatTaoluenzuLikeClk(o,data);
						break;
						case 200 : //未登录
							$.guang.dialog.login();
						break;
					}
				}
			});
		}
	};
	
	
	//评论操作
	$.guang.cmt = {
		limitMinNum : 4,//评论最少可输入2个汉字，4个字符
		limitMaxNum : 256,//评论最大可输入256字，512字符
		//喜欢评论提交成功
		lkCommentSubmitOkClk : function(cmtContent){},
		//喜欢评论
		lkComment: function(o){
			var productId = $("#J_HiddenProductId").val();
			if(!$("#cmtDialog")[0]){
				var html = "";
				html += '<div id="cmtDialog" class="c-dialog">';
				html += '<p class="title clearfix"><a class="cmtclose fr" href="javascript:;">x</a>喜欢了~</p>';
				html += '<div id="cmt-form">';
				html += '<div class="error-row error-like"><p class="error"></p></div>';
				html += '<div><textarea class="cmt-txa" name="commentContent" placeholder="说说喜欢的理由吧~"></textarea>';
				html += '<input type="hidden" name="commentType" value="0"/></div>';
				html += '<div class="cmt-act tar"><input type="submit" id="J_LkCommentSubmit" class="pub" value="发布"/></div>'
				html += '</div>';
				$("body").append(html);
				$(".cmt-txa").focus(function(){	
					var T = $("#cmtDialog").offset().top;			
					$("#cmtDialog").css({
						top: T - 50 + "px",
						height: 104
					});
					$(this).height(50);	
					$(".cmt-txa").unbind("focus");
				});
			}else{
				$("#cmtDialog").find("textarea").val("");
				$("#cmtDialog").fadeIn();
			}				
			var position = $.guang.util.getPosition(o).topMid();
			var W = $("#cmtDialog").outerWidth(),
			H = $("#cmtDialog").outerHeight();
			$("#cmtDialog").css({
				left: position.x - W/2 + "px",
				top: position.y - H - 12 + "px"
			}).fadeIn();
			var isEnable = "true";
			$("#J_LkCommentSubmit").unbind("click").click(function(event){
				event.preventDefault();
				if(isEnable == "false"){
					return false;
				}else{
					isEnable = "false";
				}
				if(!$("#J_HiddenProductId")[0]){
					productId = o.attr("data-proid");
				}
				$.guang.judgement.cmtSubmitOkClk = function(){
					$("#cmtDialog").fadeOut();
					$.guang.cmt.lkCommentSubmitOkClk($.guang.util.trim($("#cmtDialog").find("textarea[name='commentContent']").val()));
				}
				$.guang.judgement.cmtSubmit(productId, $("#cmtDialog"), $("#cmt-form"), "like");
				isEnable = "true";
			});
			$(".cmtclose").unbind("click").click(function(){
				$("#cmtDialog").fadeOut();
			});
		},
		//值得评论提交成功
		commentSubmitOkClk : function(cmtContent){},
		//值得评论
		comment: function(o){
			var dataType = o.attr("data-type");
			var productId = $("#J_HiddenProductId").val();
			if(!$("#commentDialog")[0]){
				var html = "";
				html += '<div id="commentDialog" class="g-dialog">';
				html += '<div class="dialog-content">';
				html += '<div class="hd"><h3>添加评论</h3></div>';
				html += '<div class="bd clearfix">';
				html += '<div id="comment-form">';
				html += '<div class="error-row error-worth"><p class="error worth-error"></p></div>';
				html += '<div class="form-row">';
				html += '<textarea class="b-textarea cmt-txa" name="commentContent" placeholder="说说你的理由吧~"></textarea><input type="hidden" name="commentType" value="' + dataType + '"/></div>';
				html += '<div class="clearfix"><input type="submit" class="bbl-btn pub" id="J_WorthCommentSubmit" value="发布"/></div>';
				html += '</div>';
				html += '</div>';
				html += '<a class="close" href="javascript:;"></a>';
				html += '</div>';
				html += '</div>';
				$("body").append(html);
				$("#commentDialog").overlay({
					top: 'center',
					mask: {
						color: '#000',
						loadSpeed: 200,
						opacity: 0.3
					},
					closeOnClick: false,
					load: true			
				});
				var isEnable = "true";
				$("#J_WorthCommentSubmit").click(function(){
					if(isEnable == "false"){
						return false;
					}else{
						isEnable = "false";
					}
					if(!$("#J_HiddenProductId")[0]){
						productId = o.attr("data-proid");
					}
					$.guang.judgement.cmtSubmitOkClk = function(){
						$("#commentDialog").overlay().close();
						$.guang.cmt.commentSubmitOkClk($.guang.util.trim($("#commentDialog").find("textarea[name='commentContent']").val()));
					}
					$.guang.judgement.cmtSubmit(productId, $("#commentDialog"), $("#comment-form"), "worth");
					isEnable = "true";
				});
			}else{
				$("#commentDialog").data("overlay").load();
				$("#commentDialog").find("textarea").text("");
			}
		},
		//鉴定评论加标签提交成功
		commentAndAddTagsSubmitOkClk : function(){},
		//鉴定评论加标签
		commentAndAddTags:function(_o,_identify,_bought,_snsProName,_snsImg,_snsProUrl,_tags,_from){
			if(_o.attr("data-proname")&&_o.attr("data-proname").length>0){_snsProName=_o.attr("data-proname")}
			if(_o.attr("data-proimgsrc")&&_o.attr("data-proimgsrc").length>0){_snsImg=_o.attr("data-proimgsrc")}
			if(_o.attr("data-prourl")&&_o.attr("data-prourl").length>0){_snsProUrl=_o.attr("data-prourl")}
			var _commentAndAddTags = function(__identify,__bought,__tags){
				var property = {};//评论属性参数（喜欢，买过，值得，不值得）
				var callbackPramToUI = {//需要给商品详细页的参数
					identify:"",
					bought:""
				};
				
				//组织评论模块html需要的变量
				var commentTitleText = "评论";
				var xihuanText = "我觉得这个宝贝：";
				var isBought = __bought=="1"?"":'<input type="checkbox" id="J_Bought" name="bought"/>'//需要后台识别
				var commentHTML = '<a href="javascript:void(0);" class="radioclick worth-radioclick-off mr10" name="worth" data-type="1"><span>值得</span></a>'
								+ '<a href="javascript:void(0);" class="radioclick worth-radioclick-off mr10" name="worth" data-type="0"><span>不值得</span></a>';
				var commentTip = "说说你的理由吧~";
				if(jQuery.trim(__identify).length){
					xihuanText = "我认为它：";
					commentHTML = __identify=='1'?'<span class="ml10 mr10 fl worth" style="color:#090">值得</span>':'<span class="ml10 mr10 fl worth" style="color:#F60">不值得</span>';
				}
				if(_o.data("type")==0){
					commentTitleText = "喜欢了～";
					property.like = 1;//装载like参数
					commentTip = "说说喜欢的理由呗～";
				}else if(_o.data("type")==1||_o.data("type")==2){
					commentTitleText = "鉴定";
					commentHTML = _o.data("type")==1?'<span class="ml10 mr10 fl worth" style="color:#090">值得</span>':'<span class="ml10 mr10 fl worth" style="color:#F60">不值得</span>'
					property.identify = _o.data("type")==1?1:0;//装载identify参数
				}else if(_o.data("type")==3){
					commentTitleText = "评论";
					commentTip = "";
				};

				//组织常用标签html
				var tagsHTML = "";
				if(__tags[0]){
					for(var i=0;i<__tags.length;i++){
						tagsHTML += '<li>'+__tags[i]+'</li>'
					}
				}
				//组织评论加标签html
				var html = ""
				+'<div id="commentDialog" class="g-dialog" style="z-index: 9999; top: 363.5px; left: 643px; position: fixed; display: block; ">'
					+'<div class="dialog-content">'
						+'<div class="hd"><h3>'+ commentTitleText +'</h3></div>'
						+'<div class="bd clearfix">'
							+'<div id="comment-form">'
								+'<div class="error-row error-worth"><p class="error worth-error"></p></div>'
								+'<div class="commentText-row">'
									+'<div class="commentText-hd clearfix">'
										+'<h4 class="fl">'+ xihuanText +'</h4>'
										+commentHTML
										+'<span class="bought fl">'
											+isBought+'<label for="J_Bought">我买过</label>'
										+'</span>'
									+'</div>'
									+'<div class="commentText-bd">'
										+'<textarea class="b-textarea cmt-txa" name="commentContent" id="J_CommentContent" placeholder="'+commentTip+'"></textarea>'
										+'<p><span class="msg" id="J_CommentError"></span>还可以输入<em id="J_CommentCount">256</em>字</p>'
									+'</div>'
								+'</div>'
								+'<div class="commentTags-row">'
									+'<h4>宝贝标签<span>（多个标签用空格、中文或英文逗号隔开）</span>：</h4>'
									+'<input class="b-input" type="input" name="commentTags" id="J_CommentTags"/>'
								+'</div>'
								+'<div class="usedTags-row">'
									+'<h4>常用标签：</h4>'
									+'<ul class="clearfix">'+tagsHTML+'</ul>'
								+'</div>'
								+'<div class="clearfix pt10">'
									+'<input type="submit" class="bbl-btn pub" id="J_WorthCommentSubmit" value="确定">'
									+'<div class="share-comment">'
										+'<span class="gc">同步分享：</span>'
										+'<ul id="J_UserSns">'
										+'</ul>'
										+'<span><a href="'+GUANGER.path+'/account/sns" target="_blank">设置</a></span>'
									+'</div>'
									+'<div class="taobao-favorite">'
										+'<input type="checkbox" id="J_Taobaofavorite"/>'
										+'<label for="J_Taobaofavorite">收藏到淘宝</label>'
									+'</div>'
								+'</div>'
							+'</div>'
						+'</div>'
						+'<a class="close" href="javascript:;"></a>'
					+'</div>'
				+'</div>';
				$("body").append(html);
				
				//显示评论框
				$("#commentDialog").overlay({
					top: 'center',
					mask: {
						color: '#000',
						loadSpeed: 200,
						opacity: 0.3
					},
					closeOnClick: false,
					load: true,
					onClose: function() {
						$("#commentDialog,#exposeMask").remove();
					}				
				});
				
				//评论计数，还可以输入xx字
				$.guang.wordCount.conf.errorClk = function(newLen){
					$("#J_CommentCount").text('trimming...  ' + ($.guang.cmt.limitMaxNum - newLen));
				}
				$.guang.wordCount.init($("#J_CommentContent"), $("#J_CommentCount"), $.guang.cmt.limitMaxNum, 20);	
				
				//ajax填充分享平台
				var snaMap = {
					type_3:'<li class="share-switch ss-sina-btnclick-on btnclick" data-status="on" data-snsid="3" data-webname="ss-sina"></li>',//SNS_TYPE_SINA = 3;
					//type_4:'',//SNS_TYPE_TENCENT_QQ = 4;
					type_5:'<li class="share-switch ss-tencent-btnclick-on btnclick" data-status="on" data-snsid="5" data-webname="ss-tencent"></li>'//SNS_TYPE_TENCENT_WEIBO = 5;
					//type_6:'<li class="share-switch ss-douban-btnclick-on btnclick" data-status="on" data-webname="ss-douban"></li>',//SNS_TYPE_DOUBAN = 6;
					//type_7:'<li class="share-switch ss-renren-btnclick-on btnclick" data-status="on" data-webname="ss-renren"></li>',//SNS_TYPE_RENREN = 7;
					//type_8:'',//SNS_TYPE_TAOBAO = 8;
					//type_9:'',//SNS_TYPE_ZHIFUBAO = 9;
					//type_10:'<li class="share-switch ss-163-btnclick-on btnclick" data-status="on" data-webname="ss-163"></li>'//SNS_TYPE_NETEASE = 10;
				}
				//'<li class="share-switch ss-qzone-btnclick-on btnclick" data-status="on" data-webname="ss-qzone"></li>'保留qzone
				var J_UserSns_Dom = $("#J_UserSns");
				$.ajax({
					url: GUANGER.path+"/account/getUserSns.html",
					type : "post",
					dataType: "json",
					success: function(data){
						if(data.code==100){
							var shareHTML = "";
							var unites = data.userSns;
							for(var i=0;i<unites.length;i++){
								if(snaMap["type_"+unites[i]]){
									shareHTML += snaMap["type_"+unites[i]];
								}
							}
							J_UserSns_Dom.append(shareHTML);
							$(".btnclick").bind("click",function(){
								var $this = $(this);
								var classOn = $this.attr("data-webname")+"-btnclick-on";
								var classOff = $this.attr("data-webname")+"-btnclick-off";
								if($this.data("status")=="on"){
									$this.removeClass(classOn).addClass(classOff).data("status","off");
								}else{
									$this.removeClass(classOff).addClass(classOn).data("status","on");
								}
							})
						}
					}
				});
				//ajax填充加入淘宝收藏夹
				
				if(_o.attr("data-type")=="0"){
					var taobaofavorite = $(".taobao-favorite");
					taobaofavorite.show();
					/*
					$.ajax({
						url: GUANGER.path+"/taobao/checkFavorite",
						type : "post",
						dataType: "json",
						data:{
							productId:_o.attr("data-proid")
						},
						success: function(data){
							switch(data.code){
								case 100:
									//宝贝有淘宝店铺，用户也绑定了淘宝帐号
									taobaofavorite.show();
									if(data.itemId){
										TBFavInput.data("itemid",data.itemId)
									}
								break;
								case 103:
									//非淘宝第三方用户，且没有验证邮箱
									taobaofavorite.show();
									taobaofavorite.html('<a href="'+GUANGER.path+'/account/basic" target="_blank">收藏到淘宝<a>')
								break;
								case 105:
									//用户没有绑定淘宝帐号
									taobaofavorite.show();
									taobaofavorite.html('<a href="'+GUANGER.path+'/account/snsLogin?snsType=8" target="_blank">收藏到淘宝<a>')
								break;
								case 110:
									//宝贝没有淘宝店铺
									taobaofavorite.show();
									if(TBFavInput.legnth==1){
										TBFavInput[0].checked=false;
										TBFavInput[0].disabled="disabled";
									}
								break;
								case 300:
									//未登录
								break;
								default:  
								break;
							}
						}
					});
					*/
				}
				
				//点击常用标签事件
				$(".usedTags-row li").click(function(){
					var commentTags = $("#J_CommentTags").val().replace(/^[\uff0c\,]+/,"").replace(/[\uff0c\,]+$/,"");
					var commentTagsTmp = ","+commentTags+",";
					var $this = $(this);
					if($this.hasClass("selected")){
						var replaceAll = function(string,formStr,toStr){
							var resultStr = string.replace(formStr,toStr);
							while(resultStr.indexOf(formStr)>=0){
								resultStr = resultStr.replace(formStr,toStr);
							}
							return resultStr;
						}
						var commentTagsRemove = replaceAll(commentTagsTmp,","+$this.text()+",",",").replace(/^[\uff0c\,]+/,"").replace(/[\uff0c\,]+$/,"");
						$("#J_CommentTags").val(commentTagsRemove);
						$this.removeClass("selected");
					}else{	
						var commentTagsAdd = commentTags.length?(commentTags+","+$this.text()):$this.text();
						if($.guang.util.getStrLength($.guang.util.htmlToTxt(commentTagsAdd))<=64){
							$("#J_CommentTags").val(commentTagsAdd)
							$this.addClass("selected");
						}else{
							$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
							$.guang.tip.show($this,">_< 标签内容不能超过64个汉字！");
						}
					}
				})
				
				//手动输入标签事件
				$("#J_CommentTags").keyup(function(e){
					//限制每个标签的中文长度
					var MaxSingleTagLength = 14;
					var MaxAllTagsLength = 64;
					var thisVal = this.value;
					if($.guang.util.getStrLength($.guang.util.htmlToTxt(thisVal))<=MaxAllTagsLength){
						var $this = $(this);
						thisVal = thisVal.replace(/\uff0c|\s+/g,",");
						while(thisVal.indexOf(',,')>=0){
							thisVal = thisVal.replace(',,',',')
						}
						var thisValueArr = thisVal.split(",");
						var thisValueArrIndex = 0;
						var istoolong = false;
						for(;thisValueArrIndex<thisValueArr.length;thisValueArrIndex++){
							var val = thisValueArr[thisValueArrIndex]
							if($.guang.util.htmlToTxt(val).length>MaxSingleTagLength){
								istoolong = true;
								thisValueArr[thisValueArrIndex] = $.guang.util.substring4ChAndEn(val,MaxSingleTagLength);
							}
						}
						if(istoolong){
							thisVal = thisValueArr.join(",");
						}
						if(thisVal != this.value){
							this.value = thisVal;
						}
						$(".usedTags-row li").each(function(){
							var $li = $(this)
							if((","+this.value+",").indexOf(","+$li.text()+",")>=0){
								$li.hasClass("selected")?"selected":$li.addClass("selected");
							}else{
								$li.hasClass("selected")?$li.removeClass("selected"):"noselected";
							}
						})
					}else{
						this.value = $.guang.util.substring4ChAndEn(thisVal,64);
					}
				})
				
				//radioclick和btnclick事件代理
				$(".radioclick").click(function(){
					var $this = $(this);
					var classOn = $this.attr("name")+"-radioclick-on";
					var classOff = $this.attr("name")+"-radioclick-off";
					if($this.hasClass(classOn)){
						$this.removeClass(classOn).addClass(classOff);
					}else{
						$("."+classOn).removeClass(classOn).addClass(classOff);
						$this.removeClass(classOff).addClass(classOn);
					}
				})
				
				//评论提交
				var isEnable = "true";
				$("#J_WorthCommentSubmit").click(function(){
					var $this = $(this);
					if(isEnable == "false"){
						return false;
					}else{
						isEnable = "false";
					}
					
					//表单校验
					var commentContent = $("#J_CommentContent").val();
					var commentTags = $("#J_CommentTags").val();
					//2~256个汉字
					if(commentContent != "" && $.guang.util.getStrLength(commentContent) >=2){
						if($.guang.util.getStrLength(commentContent) > 256){
							//超过256个汉字提示
							$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
							//$.guang.tip.show($this,">_< 评论内容不能超过1000个汉字！");
							$.guang.tip.show($this,">_< 评论内容不能超过256个汉字！");
							isEnable = "true";
							return false;
						}
					}else{//评论为空提示
						$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
						//$.guang.tip.show($this,">_< 评论内容不能为空！");
						$.guang.tip.show($this,">_< 你的评论太短啦，再多说几句吧！");
						isEnable = "true";
						return false;
					}
					if($.guang.util.getStrLength(commentTags) > 64){
						//超过256个汉字提示
						$.guang.tip.conf.tipClass = "tipmodal tipmodal-general";
						$.guang.tip.show($this,">_< 标签内容不能超过64个汉字！");
						isEnable = "true";
						return false;
					}
						
					//获取评论框选择和输入的内容
					if($("#J_Bought:checked").length>0){
						property.bought = 1;//装载bought参数
						callbackPramToUI.bought = "1";
					}
					if($(".worth-radioclick-on").length>0){
						property.identify = parseInt($(".worth-radioclick-on").eq(0).attr("data-type"),10);//装载identify参数
						callbackPramToUI.identify = $(".worth-radioclick-on").eq(0).attr("data-type");
					}
					var data = {
						productId : _o.attr("data-proid"),
						sid : _o.data("sid")?_o.data("sid"):"",
						commentContent : commentContent,
						tagNames : $("#J_CommentTags").val(),
						snsSiteIds:"",
						productImgUrl:_snsImg ,
						commentContent4Sns:""
					}
					$.extend(data,property);
					//设置淘宝收藏夹参数
					if(_o.attr("data-type")=="0"){
						data.taobaoFavorite = $("#J_Taobaofavorite")[0].checked?1:0;
						//data.itemId = TBFavInput.data("itemid");
					}
					//data.snsSiteIds
					if($("#J_UserSns li").length>0){
						for(var k=0;k<$("#J_UserSns li").length;k++){
							if($("#J_UserSns li").eq(k).data("status")=="on"){
								var snsSiteId = $("#J_UserSns li").eq(k).data("snsid")
								data.snsSiteIds += data.snsSiteIds.length>0?","+snsSiteId:snsSiteId;
							}
						}
					}
					//data.commentContent4Sns
					var snsHead = {
						0:"喜欢，",
						1:"这宝贝值，推荐：",
						2:"这宝贝不值：",
						3:"评论了《$》:"
					}

					var snsMaxLength = 140-5;//误差5个字符
					var leftSnsMaxLength = snsMaxLength - $.guang.util.getStrLength(snsHead[_o.data("type")]+_snsProName+_snsProUrl);
					if($.guang.util.getStrLength(commentContent)>leftSnsMaxLength){
						if(snsHead[_o.data("type")].indexOf("$")>=0){
							data.commentContent4Sns = snsHead[_o.data("type")].replace("$",_snsProName)+$.guang.util.substring4ChAndEn(commentContent,leftSnsMaxLength)+"..."+_snsProUrl;
						}else{
							data.commentContent4Sns = snsHead[_o.data("type")]+$.guang.util.substring4ChAndEn(commentContent,leftSnsMaxLength)+"..."+_snsProName+_snsProUrl;
						}
					}else{
						if(snsHead[_o.data("type")].indexOf("$")>=0){
							data.commentContent4Sns = snsHead[_o.data("type")].replace("$",_snsProName)+commentContent+"。"+_snsProUrl;
						}else{
							data.commentContent4Sns = snsHead[_o.data("type")]+commentContent+"。"+_snsProName+_snsProUrl;
						}
					}
					
					//设置回调函数
					$.guang.judgement.commentAndAddTagsSubmitOkClk = function($json){
						$("#commentDialog").overlay().close();
						$.guang.cmt.commentAndAddTagsSubmitOkClk($json, callbackPramToUI);
					}
					$.guang.judgement.commentAndAddTagsSubmitErrorClk = function($json){
						if($json.code==440){
							//如果评论被禁止，则关闭评论框
							$("#commentDialog").overlay().close();
						}
						//评论出错后不关闭弹窗,显示出错内容,并激活提交按钮
						isEnable = "true";
					}
					
					//小样,终于可以评论了NND
					$.guang.judgement.commentAndAddTagsSubmit(data, $(this));					
				});
			}
			
			//判断是否来自detail页面，需要调用ajax传递鉴定，购买，标签参数
			if(_from=="fromNonDetail"){
				$.ajax({
					url: GUANGER.path+"/baobei/getUserIdentifyAndBuyAndTag.html",
					type : "post",
					dataType: "json",
					data:{
						productId:_o.attr("data-proid")
					},
					success: function(data){
						if(data.code==100){
							var tags = [];
							if(data.tagList[0]){
								for(var i=0;i<data.tagList.length;i++){
									tags[tags.length] = data.tagList[i].tagKeyword;
								}
							}
							_commentAndAddTags(data.identify,data.bought,tags);
						}
					}
				});
			}else{
				_commentAndAddTags(_identify,_bought,_tags);
			}
		}
	}
})(jQuery);